package cn.pzhu.javadb;
import java.sql.*;
public class DelDemo {
	public static void main(String[] args) {
		//1.load dirver
		try {Class.forName("com.mysql.jdbc.Driver");} catch (ClassNotFoundException e) {}
		Connection conn=null;
		Statement st=null;
		String url="jdbc:mysql://localhost:3306/2012jb?useUnicode=true&characterEncoding=UTF-8";
		String userName="root";
		String password="123456";
		try {//2. connection
			conn=DriverManager.getConnection(url,userName,password);
			//3. statement  or preparestatement
			st=conn.createStatement();
			//4.execute sql ResultSet
			if(1==st.executeUpdate("DELETE FROM user WHERE ID=5")){
				System.out.println("del OK");
			}else{
				System.out.println("del ERRO");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			//6.release resource
			if(st!=null)try {st.close();} catch (SQLException e) {}
			if(conn!=null)try {conn.close();} catch (SQLException e) {}
		}

	}

}
